import os
from datetime import timedelta

class Config:
    # 基础配置
    SECRET_KEY = 'zhangyiyang_js22150333_super_secret_key_12345!'
    SITE_NAME = "张忆扬的个人主页"
    
    # 数据库配置
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://js22150333:js22150333@81.69.190.161/js22150333'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    
    # 邮件配置
    MAIL_SERVER = 'smtp.163.com'
    MAIL_PORT = 465
    MAIL_USE_SSL = True
    MAIL_USERNAME = '15116672656@163.com'
    MAIL_PASSWORD = 'TVnz8jWDrtvk2m3P'  # 注意：这是163邮箱的SMTP授权码，实际部署时应使用环境变量
    MAIL_DEFAULT_SENDER = ('张忆扬的个人主页', '15116672656@163.com')
    
    # 验证码配置
    VERIFICATION_MAIL_SUBJECT = "邮箱验证 - 张忆扬的个人主页"
    CAPTCHA_EXPIRATION = timedelta(minutes=10)
    
    # 文件上传配置
    UPLOAD_FOLDER = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'app/static/uploads')
    MAX_CONTENT_LENGTH = 16 * 1024 * 1024  # 16MB max file size
    ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}

class DevelopmentConfig(Config):
    DEBUG = True

class ProductionConfig(Config):
    DEBUG = False

# 配置映射
config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
} 